using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class ShaderAssetCollect : AssetCollection
{
    public override string fileExtensions {
        get
        {
            return "t:shader";
        }
    }

    public ShaderAssetCollect(string findPath)
    {
        this.findPath = findPath;
    }

    public override void CollectAsset()
    {
        var allAssets = AssetDatabase.FindAssets(fileExtensions);
        builds = new List<AssetBundleBuild>();
        int progress = 0;
        int max = allAssets.Length;
        EditorUtility.DisplayProgressBar("Collect Progress Bar", "collect bundle asset progress", (float)(progress *1f/ max));

        
        foreach (var guid in allAssets)
        {
            //Debug.LogError(AssetDatabase.GUIDToAssetPath(guid));
            AssetBundleBuild build = new AssetBundleBuild();
            build.assetBundleName = guid;
            build.assetNames = new string[]
            {
                AssetDatabase.GUIDToAssetPath(guid)
            };
            builds.Add(build);
            progress++;
            EditorUtility.DisplayProgressBar("Collect Progress Bar", "collect bundle asset progress", (float)(progress*1f / max));
        }
        
        EditorUtility.ClearProgressBar();
        base.CollectAsset();
    }
}
